package com.itheima.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/*
请求行上有什么？
      请求方式   url   协议/版本
      get
      post      http://localhost:8080/day04/line?username=jack   http/1.1

      既然请求行有这些信息  request就有获取这些信息的方法
        要求能看懂！！！！

 */
@WebServlet("/line")
public class RequestLineServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("获取请求方式:"+request.getMethod());
        //获取 访问的请求地址
        System.out.println("获取访问的请求地址:"+request.getRequestURL());
        //获取请求的项目虚拟路径
        System.out.println("获取项目虚拟路径:"+request.getContextPath());
        //获取当前servlet的虚拟路径
        System.out.println("获取servlet虚拟路径:"+request.getServletPath());
        // 获取远程访问地址
        System.out.println("谁访问我了:"+request.getRemoteAddr());
        //获取地址栏上的参数
        System.out.println("获取地址栏上的参数："+request.getQueryString());




    }
}
